package cn.tedu.shoot;

import java.awt.image.BufferedImage;

//英雄机
public class Hero extends FlyingObject {

	private int life; // 命
	private int fire; // 火力值
	private int energy;//能量值

	public Hero() {
		super(128, 128, 250, 800);
		life = 3;
		fire = 0;
	}

	public void step() {
		
	}


	public BufferedImage getImage() {
		return Images.hero;
	}

	public Bullet[] shoot() {
		int xStep=this.width/4;
		int yStep=60;
		if(fire>0) {
			Bullet[]bs=new Bullet[3];
			bs[0] = new Bullet(this.x+2*xStep-15,this.y-yStep);
			bs[1] = new Bulletleft(this.x+xStep-15,this.y-yStep);
			bs[2] = new BulletRight(this.x+3*xStep-15,this.y-yStep);
			fire-=2;
			return bs;
		}else {
			Bullet[]bs=new Bullet[1];
			bs[0]=new Bullet(this.x+2*xStep-15,this.y-yStep);
			return bs;			
		}
	}
	public void moveTo(int x,int y) {
		this.x=x-this.width/2;
		this.y=y-this.height/2;
	}
	public void addLife () {
		life++;
	}
	public int getLife() {
		return life;
	}
	public void subtractLife() {
		life--;
	}

	public void addFire() {
		fire+=40;
	}
	public void clearFire() {
		fire=0;
	}
	public int getFire() {
		return fire;
	}

	public int getEnergy() {
		return energy;
	}
	public void addEnergy(){
		if(fire>=50){
			energy++;
			fire-=50;
		}
	}
	public void subtractEnergy() {
		energy--;
	}

}
